define(function(require, exports, module){
    var cards = {};

    cards.init = function(targets, dropdownItems) {
        cards.render(targets);
        cards.bind(dropdownItems);
    };

    cards.bind = function(dropdownItems) {
        $(dropdownItems).hover(function(){
            var activeID = '#' + $(this).attr('data-id');
            $('.active').removeClass('active');
            $(activeID).addClass('active');
        }, function(){
            $('.active').removeClass('active');
        });
    };

    cards.render = function(targets) {
        var dropdownW = $('.dropdown').width();
        $('.cards').each(function(){
            var $wrap = $(this);
            var wrapH = $wrap.height();
            var wrapW = $wrap.width();
            var zIndex = 0;
            $('.card').each(function(){
                var $this = $(this);
                var minus = Math.random() > 0.5;
                var radius = Math.random() * 45;
                var height = $this.height();
                var width = $this.width();
                minus && (radius = minus + radius);
                $this.css({
                    'top': Math.random() * (wrapH - width / 2),
                    'left': Math.random() * (wrapW - width - dropdownW),
                    'transform': 'rotate(' + radius + 'deg)',
                    'zIndex': zIndex++
                });
            });
        });
    };

    module.exports = cards;
});